package com.sinry.message.enums;

import com.sinry.common.core.domain.dto.ApiRegisterDto;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

import static com.sinry.message.constant.QueueConst.SWAGGER_AUTO_REPORT;

/**
 * @author linxinlei
 * @project sinry-cloud
 * @description 队列信息
 * @date 2022/8/7
 **/
@Getter
@AllArgsConstructor
public enum RabbitQueue implements RabbitHandler{
    /**
     * swagger上报消息
     */
    SWAGGER_REPORT("swagger-aggregate", SWAGGER_AUTO_REPORT, ApiRegisterDto.class),
    /**
     * 消息中心
     */
    MESSAGE_CENTER("message-center", SWAGGER_AUTO_REPORT, ApiRegisterDto.class),
    ;

    private final String exchange;
    private final String queue;
    private final Class<?> messageClass;

    public static Optional<RabbitQueue> of(String exchange, String queue) {
        return Arrays.stream(RabbitQueue.values())
                .filter(e -> e.getExchange().equals(exchange) && e.getQueue().equals(queue))
                .findFirst();
    }

}
